import axios from 'axios'

export const request = axios.create({
  timeout: 10000,
  timeoutErrorMessage: '链接超时....',
})


request.interceptors.request.use((config) => {

  config.headers.token = localStorage.getItem('token');

  return config
}, error => {
  return Promise.reject(error)
})


request.interceptors.response.use(response => {
  return response;
}, error => {
  const { status } = error;
  switch(status) {
    case 400: console.log('客户端错误');break;
    case 500: console.log('服务端错误');break;
  }
  return Promise.reject(error)
})


